package display;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.mvc.Controller;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;
import java.util.HashMap;

import service.CategoriaManager;

public class CategoriaController implements Controller{
 protected final Log logger = LogFactory.getLog(getClass());
 private CategoriaManager categoriaManager;
 public ModelAndView handleRequest(HttpServletRequest request,
   HttpServletResponse response)
   throws ServletException, IOException {
   String now = (new java.util.Date()).toString();
   logger.info("returning categoria view with " + now);
   Map<String, Object> myModel = new HashMap<String, Object>();
   myModel.put("now", now);
   myModel.put("categorias", this.categoriaManager.getCategorias());
   return new ModelAndView("categoriaView", "model", myModel);
 }
 public void setCategoriaManager(CategoriaManager categoriaManager) {
   this.categoriaManager = categoriaManager;
} }